package ru.nsu.fit.iconveyor.engine.smart;

import java.util.Map;

/**
 * @author Timur Zolotuhin (tzolotuhin@gmail.com)
 */
public class Cell4Result {
    // Main data
    private final String ownerNodeId;
    private boolean complete = false;
    private Map<String, Object> result;

    // Mutex
    private final Object generalMutex = new Object();

    public Cell4Result(String ownerNodeId) {
        this.ownerNodeId = ownerNodeId;
    }

    public void complete(Map<String, Object> result) {
        synchronized (generalMutex) {
            this.result = result;
            complete = true;
        }
    }

    public boolean isComplete() {
        synchronized (generalMutex) {
            return complete;
        }
    }

    public Map<String, Object> getResult() {
        synchronized (generalMutex) {
            return result;
        }
    }
}
